package com.wlc.exception.demo03;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 测试取钱业务
 * @date 2021-07-08 16:17
 */
public class Test {

    /**
     * 存钱
     */
    public void deposit(Account account) {
        double money = 120;
        account.deposit(money);
    }

    /**
     * 获取余额
     *
     * @param account
     */
    public void getBalance(Account account) {
        double balance = account.getBalance();
        System.out.println("余额为： " + balance);
    }

    /**
     *  取钱
     * @param account
     */
    private void withdraw(Account account) {
        try {
            account.withdraw(150);
        } catch (OverdraftException e) {
            System.out.println("具体原因为：" + e.getMessage() +"透支了" +e.getDeficit());
        }
    }

    public static void main(String[] args) {

        Test test = new Test();
        Account account = new Account();
        test.getBalance(account);
        // 存钱
        test.deposit(account);
        // 查询余额
        test.getBalance(account);
        // 取钱
        test.withdraw(account);
        // 查询余额
        test.getBalance(account);
    }


}
